const initialState = {
  arr: []
}

let tablereducer = (state = initialState, {
  type,
  payload
}) => {
  switch (type) {

    case "getlist":
      let newarr = [...state.arr]
      newarr = payload
      return {
        ...state,
        arr: newarr
      }
    case "delfn" :
      let newarr1 = [...state.arr]
      newarr1.splice(payload,1)
      return {
        ...state,
        arr :  newarr1
      }
    case "addfn" :
      let newarr2 = [...state.arr]
      newarr2.push(payload)
      return {
        ...state,
        arr :newarr2
      }
    case "eidtfn":
      let newarr3 = [...state.arr]
      newarr3[payload.editindex] = payload
      return {
        ...state,
        arr: newarr3

      }
      default:
        return {
          ...state
        }
  }
}
export default tablereducer